<template>
  <div class="makeup-score-entry-container">
    <div>
      <ul>
        <li>
          <span class="active">课程编号：</span>
          <span>{{ courseno }} </span>
          <span class="active">课程名称：</span>
          <span>{{ coursename }}</span>
        </li>
        <li>
          <span class="active">成绩分制：</span>
          <span>{{ cjfz }}</span>
          <span class="active">修习类型：</span>
          <span>{{ xxlx }}</span>
        </li>
      </ul>
      <ul>
        <li>
          <span class="active">学号【姓名】</span>
          <span class="active">专业班次</span>
          <span class="active">成绩性质</span>
          <span class="active">补缓考成绩</span>
        </li>
        <li v-for="(item, index) in tableData" :key="index" ref="li">
          <span>{{ item.studentno }}【{{ item.name }}】</span>
          <span>{{ item.proclassname }}</span>
          <span>{{ item.bktype }}</span>
          <span style="padding-top: 15px;">
            <el-input
              v-model="item.bkscore"
              style="width: 60px;padding:0"
              type="text"
              @change="cf"
              :disabled="item.bhkstate == 3 || item.bhkstate == 2"
            ></el-input
          ></span>
        </li>
      </ul>
      <!-- <div class="button-group" @click="zc">
        <div>暂存</div>
      </div> -->
    </div>
    <div style="display:flex;width:100px;margin:0 auto;border:none">
      <div class="button-group" @click="querySave" style="margin-left:20px">
        <div>保存</div>
      </div>
    </div>
  </div>
</template>

<script>
import {
  queryList,
  query,
  querybkzc
} from "../../../api/courseAchievement/makeupScoreEntry";
import attendClassVue from '../../teaching/frontlineData/attendClass.vue';

export default {
  name: "makeupScoreEntry",
  data() {
    return {
      coursenumber: "",
      coursename: "",
      scoretypecode: "",
      studytype: "",
      input: "",
      input1: "",
      tableData: [],
    };
  },
  mounted() {
    this.queryList();
  },
  methods: {
    //补缓考成绩input改变
    cf() {
    },
    //获取页面数据
    queryList () {
      return new Promise(() => {
        queryList(this.$route.query.planid).then((res) => {
            this.courseno = res.data.data.length > 0 ? res.data.data[0].courseno : '';
            this.coursename = res.data.data.length > 0 ?  res.data.data[0].coursename : '';
            this.cjfz = res.data.data[0].cjfz;
            this.xxlx = res.data.data[0].xxlx;
            this.tableData = res.data.data;
        });
      });
    },
    //暂存
    /* zc(){
       return new Promise(() => {
        querybkzc(this.tableData).then((res) => {
          this.tableData = res.data.data;
          console.log(res.data.data);
        });
      });
    }, */
    //保存
    querySave: function (index) {
      let arr = [];
      for (let i = 0; i < this.tableData.length; i++) {
        arr.push(this.tableData[i].bhkstate)
        if (this.tableData[i].oldmakeupscore) {
          this.tableData[i].oldstate = 2;
        } else {
          this.tableData[i].oldstate = 1;
        }
      }
      console.log(arr)
      if(arr.includes('1')){
        this.$confirm('提交之后无法进行修改，确认要提交吗？')
          .then(_ => {
            return new Promise(() => {
              query(this.tableData).then((res) => {
                if(res.data.code == 200) {
                  this.$message({
                    type: "success",
                    message: "保存成功!",
                  });
                  this.queryList();
                  this.$router.push({
                    path: "/admin/scoreManagement/delayTest"
                  });
                }
              });
            });
          })
      } else {
        this.$router.push({
          path: "/admin/scoreManagement/delayTest"
        });
      }
    },
  },
};
</script>

<style scoped lang="less">
.makeup-score-entry-container {
  > div {
    width: 100%;
    height: 100%;
    border: 1px solid rgba(0, 76, 167, 0.8);
    border-radius: 6px;
    margin: 0;

    ul {
      list-style: none;

      li {
        border-bottom: 1px solid rgba(0, 76, 167, 0.4);
        height: auto;

        > span {
          display: inline-block;
          font-size: 14px;
          color: rgba(0, 76, 167, 1);
          padding-left: 54px;
          border-right: 1px solid rgba(0, 76, 167, 0.4);
          height: 70px;
          vertical-align: middle;
          padding-top: 24px;

          &:nth-child(n) {
            width: 357px;
          }

          &:nth-child(2n) {
            width: 444px;
          }

          &:last-child {
            border-right: none;
          }

          &.active {
            font-size: 16px;
            color: rgba(0, 76, 167, 1);
            font-weight: bold;
            background: rgba(77, 129, 192, 0.1);
            text-align: center;
            padding-left: 0;
          }
        }
      }

      &:nth-child(1) {
        li {
          > span {
            height: 70px;
          }
        }
      }

      &:nth-child(2) {
        margin-top: 33px;

        li {
          height: auto;
          border-bottom: 1px solid rgba(0, 76, 167, 0.4);

          > span {
            width: 25%;
            text-align: center;
            padding-left: 0;
            height: 70px;

            &.active {
              border-top: 1px solid rgba(0, 76, 167, 0.4);
            }
          }
        }
      }
    }

    .button-group {
      text-align: center;
      margin-top: 76px;
      cursor: pointer;

      > div {
        display: inline-block;
        /* width: 74px;
        height: 27px; */
        background: rgba(241, 255, 248, 1);
        border: 1px solid #02c86c;
        border-radius: 4px;
        font-size: 18px;
        font-weight: 400;
        color: #02c86c;
        text-align: center;
        padding: 6px 20px;
      }
    }
  }
}
</style>
